package Eyjafjalla.card.attack;

import Eyjafjalla.action.EyjafjallaAttackAction;
import Eyjafjalla.action.MakeTempCardInCloudAction;
import Eyjafjalla.action.UpgradeAllBurnAction;
import Eyjafjalla.card.AbstractEyjafjallaCard;
import Eyjafjalla.helper.EyjafjallaHelper;
import Eyjafjalla.modcore.EyjafjallaTag;
import com.megacrit.cardcrawl.actions.AbstractGameAction;
import com.megacrit.cardcrawl.actions.common.DamageAction;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.cards.DamageInfo;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.localization.CardStrings;
import com.megacrit.cardcrawl.monsters.AbstractMonster;

public class HappinessAria_Eyjafjalla extends AbstractEyjafjallaCard {
    public static final String ID = "HappinessAria_Eyjafjalla";
    private static final CardStrings cardStrings;
    boolean extended = false;

    public HappinessAria_Eyjafjalla(){
        super(ID, cardStrings.NAME,0,cardStrings.DESCRIPTION,CardType.ATTACK,CardRarity.UNCOMMON,CardTarget.ENEMY);
        this.baseMagicNumber =1;
        this.magicNumber = 1;
        setFireDescription(cardStrings.EXTENDED_DESCRIPTION[0]);
    }

    @Override
    public void calculateCardDamage(AbstractMonster mo) {
        baseDamage = (EyjafjallaHelper.countBurnUpgrades()+(isFire()?2:1)*EyjafjallaHelper.countBurnCards())*this.magicNumber;
        super.calculateCardDamage(mo);
        isDamageModified = baseDamage!=damage;
        setDescriptionRaw(damage>0);
    }

    @Override
    public void applyPowers() {
        baseDamage = (EyjafjallaHelper.countBurnUpgrades()+(isFire()?2:1)*EyjafjallaHelper.countBurnCards())*this.magicNumber;
        super.applyPowers();
        isDamageModified = baseDamage!=damage;
        setDescriptionRaw(damage>0);
    }

    @Override
    public void onMoveToDiscard() {
        setDescriptionRaw(false);
    }

    @Override
    public AbstractCard makeCopy() {
        return new HappinessAria_Eyjafjalla();
    }

    @Override
    public void use(AbstractPlayer p, AbstractMonster m) {
        addToBot(new EyjafjallaAttackAction());
        addToBot(new UpgradeAllBurnAction(isFire()?2:1));
        addToBot(new DamageAction(m,new DamageInfo(p,damage,damageTypeForTurn), AbstractGameAction.AttackEffect.FIRE));
    }

    private void setDescriptionRaw(boolean show){
        if(show&&!extended){
            rawDescription = cardStrings.DESCRIPTION+cardStrings.EXTENDED_DESCRIPTION[1];
            initializeDescription();
            extended = true;
        }
        else if(!show&&extended){
            rawDescription = cardStrings.DESCRIPTION;
            initializeDescription();
            extended = false;
        }
    }

    @Override
    public void upgrade() {
        if(!this.upgraded){
            upgradeName();
            upgradeMagicNumber(1);
        }
    }

    static {
        cardStrings = CardCrawlGame.languagePack.getCardStrings(ID);
    }
}

